package com.njits.traffic.oscache;
public class CacheManager {
	private BaseCache newsCache;
	private static CacheManager instance;
	private static Object lock = new Object();

	private CacheManager() {
		newsCache = new BaseCache("news", 120);
	}

	public static CacheManager getInstance() {
		if (instance == null) {
			synchronized (lock) {
				if (instance == null) {
					instance = new CacheManager();
				}
			}
		}
		return instance;
	}

	public void putPageCount(String key,String pageCount) {
		newsCache.put(key, pageCount);
	}

	public void removeUser(String newsID) {
		newsCache.remove(newsID);
	}

	public String getPageCount(String key) {
		String pageCount = null;
		try {
			pageCount = (String) newsCache.get(key);
		} catch (Exception e) {
			pageCount = "-1";
		}
		return pageCount;
	}

	public void removeAllNews() {
		newsCache.removeAll();
	}
}
